package koala.kuangjiademo.data;

import com.google.gson.annotations.SerializedName;
import com.wwgps.ect.R;

import java.io.Serializable;

public class Order implements Serializable {
    public int id;

    public String getTaskId() {
        return String.valueOf(id);
    }

    /**
     * 编号
     */
    @SerializedName("processInstanceId")
    public String number;

    /**
     * 单号
     */
    public String getOrderNumber() {
        return number;
    }

    /**
     * 工单类型，新：pro_01
     */
    private String processDefinitionId;
    private OrderType type;
    /**
     * 描述信息
     */
    @SerializedName("description")
    private String message;

    public String getMessage() {
        return message;
    }


    public int getIcon() {
        return getType().icon;
    }

    public OrderType getType() {
        return type != null ? type : (type = OrderType.get(processDefinitionId));
    }

    public enum OrderType {
        install(R.drawable.order_type_icon_install),
        remove(R.drawable.order_type_icon_remove),
        fix(R.drawable.order_type_icon_fix),
        unkown(R.drawable.order_type_icon_fix);
        public final int icon;

        OrderType(int icon) {
            this.icon = icon;
        }

        public static OrderType get(String processDefinitionId) {
            if (processDefinitionId.startsWith("proc_new_build")) {
                return install;
            } else if (processDefinitionId.startsWith("proc_new_back")) {
                return remove;
            } else if (processDefinitionId.startsWith("proc_vindicate")) {
                return fix;
            }
            return unkown;
        }
    }

    public static class Response extends ResponsePacket<Data> {
    }

    public static class Data extends IPacketPagedResponse<Order> {
    }
}
